package com.fingard.dsp.bank.directbank.weixin01;

import com.fingard.dsp.bank.directbank.FailCode;
import com.fingard.dsp.bank.directbank.bankInterface.IBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.ReqBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.ReqQryBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsQryBatPayRec;
import com.fingard.dsp.bank.reqrespobj.single.ReqQrySingle;
import com.fingard.dsp.bank.reqrespobj.single.ReqSingle;
import com.fingard.dsp.bank.reqrespobj.single.RetAtsSingle;

public class WEIXIN01BatPayRec extends WEIXIN01Base implements IBatPayRec {
    @Override
    public RetAtsBatPayRec d_1988_BatPay(ReqBatPayRec p_req1988) throws Exception {
        return null;
    }

    @Override
    public RetAtsQryBatPayRec d_1998_QryBatPay(ReqQryBatPayRec p_req1998) throws Exception {
        return null;
    }

    @Override
    public RetAtsBatPayRec d_9188_BatPay(ReqBatPayRec p_req9188) throws Exception {
        RetAtsBatPayRec retAts = new RetAtsBatPayRec(p_req9188.reqHeader);
        if("918801CNVRT".equals(p_req9188.reqHeader.commandCode)) {
            if(p_req9188.getTotalNum() == 1){
                ReqSingle req9108 = new ReqSingle(p_req9188);//批量转单笔
                WEIXIN01RealTime tmpRealTime = new WEIXIN01RealTime();
                tmpRealTime.setSbLog(this.sbLog);
                tmpRealTime.setLogFlushTime(this.logFlushTime);
                tmpRealTime.reqHeader = req9108.reqHeader;
                tmpRealTime.bankFront = this.bankFront;
                req9108.singleDetail.askNumber = p_req9188.reqBatchNO;//批次号作为单笔流水号
                RetAtsSingle retAts9108 = tmpRealTime.d_9108_RealTimeRec(req9108);
                retAts9108.fillToBatRetAts(retAts);
            }else{
                retAts.fillBatchFailed(p_req9188, FailCode.E9981, "总笔数需为1");
            }
        }else{
            retAts.fillBatchFailed(p_req9188, FailCode.E9981, "未实现该接口");
        }
        retAts.writeRetToATS();
        return retAts;
    }

    @Override
    public RetAtsQryBatPayRec d_9198_QryBatPay(ReqQryBatPayRec p_req9198) throws Exception {
        RetAtsQryBatPayRec retAts = new RetAtsQryBatPayRec(p_req9198.reqHeader);
        if("918801CNVRT".equals(p_req9198.reqHeader.commandCode)){
            ReqQrySingle req9144 = new ReqQrySingle(p_req9198);//批量转单笔
            WEIXIN01RealTime tmpRealTime = new WEIXIN01RealTime();
            tmpRealTime.setSbLog(this.sbLog);
            tmpRealTime.setLogFlushTime(this.logFlushTime);
            tmpRealTime.reqHeader = req9144.reqHeader;
            tmpRealTime.bankFront = this.bankFront;
            RetAtsSingle ret9144 = tmpRealTime.d_9144_QryRealTimeRec(req9144);
            ret9144.fillToBatRetAts(retAts);
        }else{
            retAts.respCode = "-1";
            retAts.respInfo = "未实现该接口";
        }
        retAts.writeAfterDetail();
        return retAts;
    }
}